package main

import (
	"gopkg.in/gin-gonic/gin.v1"
	"micr/base"
	"micr/router"
	"runtime"
	"strconv"
)

func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	base.ConsoleWrite("服务器CPU数量："+ strconv.Itoa(runtime.NumCPU()))
	base.ConsoleWrite("Golang运行数量："+ strconv.Itoa(runtime.NumGoroutine()))
	//获取数据库配置文件路径
	gin.SetMode(*base.GinMode)
	//gin.SetMode(gin.ReleaseMode)
	base.ConsoleWrite("服务器开始初始化")
	r := gin.Default()
	router.RouterV1(r)
	router.RouterV2(r)
	r.NoRoute(func(c *gin.Context) {
		base.LoggerWrite("info","接口方法不存在",c.Request.URL,c.Request.Body)
		c.JSON(200, gin.H{
			"status":     1,
			"statusCode": "接口方法不存在",
			"data":       "",
		})
	})
	r.Run(":" + *base.Port) // listen and server on 0.0.0.0:8000

}
